<?php

/**
 * This is the model class for table "pdm_tersangka".
 *
 * The followings are the available columns in table 'pdm_tersangka':
 * @property string $id
 * @property string $nama
 * @property string $tempat_lahir
 * @property string $tgl_lahir
 * @property string $sex
 * @property string $warga_negara
 * @property string $tempat_tinggal
 * @property string $agama
 * @property string $pekerjaan
 * @property string $pendidikan
 * @property string $pasal_bukti
 * @property string $pasal_dakwaan
 * @property string $hal_berat
 * @property string $hal_ringan
 * @property string $tuntutan
 * @property string $amar_putusan
 * @property string $status
 * @property string $tgl_eksekusi
 * @property string $id_perkara
 */
class PdmTersangka extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'pdm_tersangka';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('nama, sex, id_perkara', 'required'),
			array('nama, tempat_lahir, tempat_tinggal', 'length', 'max'=>100),
			array('sex, id_perkara', 'length', 'max'=>10),
			array('warga_negara', 'length', 'max'=>30),
			array('agama, pendidikan', 'length', 'max'=>20),
			array('pekerjaan, status', 'length', 'max'=>50),
			array('tgl_lahir, pasal_bukti, pasal_dakwaan, hal_berat, hal_ringan, tuntutan, amar_putusan, tgl_eksekusi', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, nama, tempat_lahir, tgl_lahir, sex, warga_negara, tempat_tinggal, agama, pekerjaan, pendidikan, pasal_bukti, pasal_dakwaan, hal_berat, hal_ringan, tuntutan, amar_putusan, status, tgl_eksekusi, id_perkara', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'nama' => 'Nama',
			'tempat_lahir' => 'Tempat Lahir',
			'tgl_lahir' => 'Tgl Lahir',
			'sex' => 'Sex',
			'warga_negara' => 'Warga Negara',
			'tempat_tinggal' => 'Tempat Tinggal',
			'agama' => 'Agama',
			'pekerjaan' => 'Pekerjaan',
			'pendidikan' => 'Pendidikan',
			'pasal_bukti' => 'Pasal Bukti',
			'pasal_dakwaan' => 'Pasal Dakwaan',
			'hal_berat' => 'Hal Berat',
			'hal_ringan' => 'Hal Ringan',
			'tuntutan' => 'Tuntutan',
			'amar_putusan' => 'Amar Putusan',
			'status' => 'Status',
			'tgl_eksekusi' => 'Tgl Eksekusi',
			'id_perkara' => 'Id Perkara',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('nama',$this->nama,true);
		$criteria->compare('tempat_lahir',$this->tempat_lahir,true);
		$criteria->compare('tgl_lahir',$this->tgl_lahir,true);
		$criteria->compare('sex',$this->sex,true);
		$criteria->compare('warga_negara',$this->warga_negara,true);
		$criteria->compare('tempat_tinggal',$this->tempat_tinggal,true);
		$criteria->compare('agama',$this->agama,true);
		$criteria->compare('pekerjaan',$this->pekerjaan,true);
		$criteria->compare('pendidikan',$this->pendidikan,true);
		$criteria->compare('pasal_bukti',$this->pasal_bukti,true);
		$criteria->compare('pasal_dakwaan',$this->pasal_dakwaan,true);
		$criteria->compare('hal_berat',$this->hal_berat,true);
		$criteria->compare('hal_ringan',$this->hal_ringan,true);
		$criteria->compare('tuntutan',$this->tuntutan,true);
		$criteria->compare('amar_putusan',$this->amar_putusan,true);
		$criteria->compare('status',$this->status,true);
		$criteria->compare('tgl_eksekusi',$this->tgl_eksekusi,true);
		$criteria->compare('id_perkara',$this->id_perkara,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return PdmTersangka the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
